﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WeiboPlus.Models;

namespace WeiboPlus.Service
{
    public interface ISNSPollingService
    {
        long SinceID
        {get;set;}

        void Start();

        void Stop();

        event EventHandler<SNSPollingEventArgs> OnPollingCompleted;

        event EventHandler<EventArgs> OnPollingStarted;

        void Config(PollingConfiguration config);
    }

    public class PollingConfiguration
    {
        bool withStatus;

        public bool WithStatus
        {
            get { return withStatus; }
            set { withStatus = value; }
        }

        long sinceID;

        public long SinceID
        {
            get { return sinceID; }
            set { sinceID = value; }
        }

        TimeSpan pollingInterval;

        public TimeSpan PollingInterval
        {
            get { return pollingInterval; }
            set { pollingInterval = value; }
        }

        public static PollingConfiguration Default
        {
            get
            {
                return new PollingConfiguration
                    {
                         PollingInterval =TimeSpan.FromSeconds(60),
                         SinceID = 0,
                         WithStatus = false
                    };
            }
        }
    }

    public class SNSPollingEventArgs : EventArgs
    {
        SNSCounts _counts;
        public SNSPollingEventArgs(SNSCounts counts)
        {
            _counts = counts;
        }
        public SNSCounts Counts { get { return _counts; } }
    }
}
